﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using System.Threading.Tasks;
using System.Timers;

namespace WinCustomsService
{
    partial class CustomsService : ServiceBase
    {
        Timer times;
        public CustomsService()
        {
            InitializeComponent();
        }

        protected override void OnStart(string[] args)
        {
            // TODO: 在此处添加代码以启动服务。
            times = new System.Timers.Timer();
            times.Interval = 10 * 1000;

            times.Elapsed += new ElapsedEventHandler(Times_Elapsed);
            times.Enabled = true;
        }
        private void Times_Elapsed(object sender, ElapsedEventArgs e)
        {
            var syncData = new ISyncData[] {
                    new Customs179Job(),
                    new Customs311Job(),
                    new Customs612Job(),

                };
            foreach(var item in syncData)
            {
                item.SyncData();
            }
        }

        protected override void OnStop()
        {
            // TODO: 在此处添加代码以执行停止服务所需的关闭操作。
            this.times.Enabled = false;
        }
    }
}
